package com.gs.cd.service.tenant.controller;


import com.gs.cd.api.ApiResult;
import com.gs.cd.api.HttpHeadersParam;
import com.gs.cd.service.auth.model.AuthUser;
import com.gs.cd.service.tenant.model.SysTenant;
import com.gs.cd.service.tenant.model.SysTenantOwnProject;
import com.gs.cd.service.tenant.model.SysTenantOwnUser;
import com.gs.cd.service.tenant.service.SysTenantOwnProjectService;
import com.gs.cd.service.tenant.service.SysTenantOwnUserService;
import com.gs.cd.service.tenant.service.SysTenantService;
import com.seven.mybatisx.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * 租户管理
 *
 * @author seven
 * @since 2020-12-22
 */
@RestController
@RequestMapping("/tenant/sysTenant")
public class SysTenantController extends AbstractController<SysTenant, SysTenantService> {

    @Autowired
    private SysTenantOwnUserService sysTenantOwnUserService;

    /**
     * 获取租户下的所有用户
     * todo 加条件模糊赛选
     *
     * @param tenantCode
     * @return
     */
    @GetMapping("search/ownUser")
    public ApiResult tenantOwnUser(@RequestHeader(HttpHeadersParam.TENANT_CODE) String tenantCode) {
        List<AuthUser> userList = sysTenantOwnUserService.listOwnUser(tenantCode);
        return ApiResult.success(userList);
    }

}

